package com.example.demo.controller;

import com.example.demo.entity.Partner;
import com.example.demo.entity.PartnerRequest;
import com.example.demo.service.PartnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/partner")
public class PartnerController {

    @Autowired
    private PartnerService partnerService;

    @GetMapping("/requests/received/{userId}")
    public List<PartnerRequest> getReceivedRequests(@PathVariable Integer userId) {
        return partnerService.getReceivedRequests(userId);
    }

    @GetMapping("/requests/sent/{userId}")
    public List<PartnerRequest> getSentRequests(@PathVariable Integer userId) {
        return partnerService.getSentRequests(userId);
    }

    @PostMapping("/request/send")
    public Boolean sendRequest(@RequestBody PartnerRequest request) {
        return partnerService.sendRequest(request);
    }

    @PutMapping("/request/handle/{id}/{status}")
    public Boolean handleRequest(@PathVariable Integer id, @PathVariable String status) {
        return partnerService.handleRequest(id, status);
    }

    @GetMapping("/list/{userId}")
    public List<Partner> getPartnerList(@PathVariable Integer userId) {
        return partnerService.getPartnerList(userId);
    }
}